<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      #box {
        width: 100px;
        height: 100px;
        background-color: green;
        position: absolute;
        left: 100px;
        top: 100px;
      }
    </style>
  </head>
  <body>
    <div id="box"></div>
    <script>
      var managerCookie = {
        set: function (name, value, date) {
          document.cookie = name + '=' + value + ';' + 'max-age=' + date;
        },
        get: function () {
          console.log(document.cookie.split('=')[1]);
        },
        remove: function (name) {
          this.set(name, '', 0);
        },
      };
      // managerCookie.set('left', 100, 20);
      // managerCookie.get();
      // managerCookie.remove('left');

      var drag = {
        init: function (dom) {
          this.dom = dom;
          this.addBind();
        },
        addBind: function () {
          document.onmousedown = this.down.bind(this);
        },
        down: function (e) {
          document.onmousemove = this.move.bind(this);
          document.onmouseup = this.up.bind(this);

          this.disX = e.clientX - this.dom.offsetLeft;
          this.disY = e.clientY - this.dom.offsetTop;
        },
        move: function (e) {
          this.newLeft = e.clientX - this.disX;
          this.newTop = e.clientY - this.disY;
        },
        up: function () {},
      };
    </script>
  </body>
</html>
